<?php
require_once '../includes/funciones.php';
include ("seguridad.php");
conexion();
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title><?php titulopanel(); ?></title>
<link rel="STYLESHEET" type="text/css" href="estilo.css"><link rel="shortcut icon" href="favicon.ico" />
<script type="text/javascript" src="../plugins/jquery.js"></script>
<script type="text/javascript" src="../plugins/jquery_validate/jquery.validate.js"></script>
<script type="text/javascript" src="../plugins/tinymce/jscripts/tiny_mce/tiny_mce.js"></script>

<?php  require_once '../includes/tinymce.html'; ?>

<script>
  $(document).ready(function(){
		
	$("#newsForm").validate({
		rules: {			
			categorie: {
				required: true,
				},
			title: {
				required: true,
					},
			summary: {
				required: true,
				},
			conten: {
					required: true,
					},	
		},				
					
                
		messages: {
			categorie: {
				required: "Seleccione una categoria"
				
						},

            title:{
                required: "Coloque un título"
                    },
                    
            summary:{
                required:"Coloque un copete"        
                     },        
            conten: "Coloque un cuerpo"		
                    
			}
	});
	
  });
 
</script>


<!-- /ERRORES -->

</head>

<body>
<div id="contenedor">

		<div id="encabezado"><?php include('header.php') ?></div><!--fin de encabezado-->



	<div id="menuizquierda"><?php include('menu.php') ?></div>	<!--fin de menuizquierda-->

	<div id="content">


	<div id="formulario">

	
	<br>
			<?php			

if(isset($_GET['var'])){
			
			$var=sqlint($_GET['var']);
			$result=mysql_query("select * from news where id=$var");

if(mysql_num_rows($result) !=0){
			while($row=mysql_fetch_array($result))
			{

			$id_news=$row['id'];
			$title=$row['title'];
			$summary=$row['summary'];
			$content=$row['content'];
			$categorie=$row['id_categories'];
			$publishedbd=$row['is_published'];
			$createdbd= $row['created'];
			
			
			

			}

			mysql_free_result($result);
}
else{ 
	$_SESSION["errorborrarnoticia"]="noexiste"; #uso la misma session de borrar noticia
	header	("location: institucionales.php");
}

?>
		

	
<span class="title">Modificar Institucional</span>	
	
			
			<br>
			<form class ="admin" id="newsForm" action="control_institucional.php" method="post"  enctype="multipart/form-data">
			<br>
			<fieldset class="admin">
			<legend>Noticia</legend>
			<p><span>Publicar:</span>
			
			<?php 
			if($publishedbd==1){
				echo '<input type="checkbox" name="published" value="1" checked />';
				 
				}else{
					
				echo '<input type="checkbox" name="published" value="1" />';		
				}
			
			
			?>
			</p>			
			<input type="hidden" name="categorie" value="5">			
			<br>  
			<p><span>T&iacute;tulo:</span>			
			<input type="text" name="title" id="title" onkeyup="if (this.value.length == 139) this.disabled = true;" size="70px" value="<?php echo $title?>">
			</p>
			<br>
			<p><span>Copete:</span>			
			<textarea name="summary" id="summary" cols="60" rows="3"><?php echo limpiar_parr($summary)?></textarea>
			</p>
			<br><br><br><br><br><br><br><br/><br/>
			<p><span>Cuerpo:</span>			
			<textarea name="conten" id="conten" cols="60" rows="10"><?php echo $content?></textarea>
			</p>
			<br>
			</fieldset>

<br>

<fieldset class="admin">
<?php 
$respfoto=mysql_query("select * from images_news where id_news='$id_news'");
		
if(mysql_num_rows($respfoto)!=0){					
	while($rows = mysql_fetch_array($respfoto)) {
		$url=$rows['url'];
		$folder=$rows['folder'];				
		echo '<img src=../'.$folder.$url.'>';
		$comment=$rows['comment'];
		echo'<br><br>Borrar Foto<br>';
		echo '<input type="checkbox" name="delpicture" value="1"/>';
		echo '<br><br>';
		
	}
}
?>
			<legend>Imagen</legend>
				<p><span>Cargar una Imagen:</span>
				<input type="file" name="imagen"><br>
				<input type="hidden" name="MAX_FILE_SIZE" value="100000">
				</p>
				
				<p><span>Comentario:</span>				
				<input type="text" name="comment" size="60" value="<?php echo $comment?>">
				</p>
				
				<br>
</fieldset>

			<input name="boton" type="hidden" id="boton" value="2"></input>
			<input name="id_news" type="hidden" id="boton" value="<?php echo $id_news?>"></input>
			<input name="publishedbd" type="hidden" id="boton" value="<?php echo $publishedbd?>"></input>
			<input name="createdbd" type="hidden" id="boton" value="<?php echo $createdbd?>"></input>
			
			
			
			<br>
			<input type="submit" class="buttonadmin" value="Modificar" style="width:75px">
			<a class="enlacecancelar" href="institucionales.php"><input type="button" class="buttoncancelar" value="Cancelar"></a>
			
			<br>
</form>

<br>
<?php }#Cierra el IF del isset($_GET['var'])?> 
	
		</div><!-- formulario -->

	</div><!--content-->


<div id="piepagina">

</div>
<!--fin de piepagina-->

</div><!-- contenedor -->

</body>

</html>